package org.cytoscape.myapp.cytoscape_app_v1.internal.UI;

import org.cytoscape.myapp.cytoscape_app_v1.internal.tasks.LayoutDefault;
import org.cytoscape.view.layout.CyLayoutAlgorithmManager;
import org.cytoscape.view.model.events.NetworkViewAddedEvent;
import org.cytoscape.view.model.events.NetworkViewAddedListener;
import org.cytoscape.work.TaskManager;


public class ViewUtilListener implements NetworkViewAddedListener {
	
	private CyLayoutAlgorithmManager layoutAlgorithmManager;
	private TaskManager taskManager;

	public ViewUtilListener(CyLayoutAlgorithmManager layoutAlgorithmManager, TaskManager taskManager) {
		this.layoutAlgorithmManager = layoutAlgorithmManager;
		this.taskManager = taskManager;
	}

	@Override
	public void handleEvent(NetworkViewAddedEvent e) {
		LayoutDefault layoutDefault = new LayoutDefault(e.getNetworkView(), layoutAlgorithmManager);
		this.taskManager.execute(layoutDefault.getLayoutIterator());
	}

	
	
}
